package com.content.view.Frame.MainPanel.MPHome
{
	
	import com.content.model.Collection.ItemGroup;
	import com.content.model.OnlineRes.NoticeVO;
	import com.content.model.OnlineRes.OnlineResHomeVO;
	import com.content.view.Frame.MainPanel.MPBase;
	
	import flash.display.Sprite;
	
	import gs.TweenLite;
	import gs.easing.Cubic;
	
	public final class MPHome extends MPBase
	{
		private var _spShowCase:SPShowCase;
		private var _spNotice:SPNotice;
		private var _spRecommand:SPRecommend;
		
		public function MPHome(	marginTop:int,
								marginBottom:int,
								marginLeft:int,
								marginRight:int,
								cBarWidth:int, 
								bgSkin:Sprite = null)
		{
			super(	this,
					marginTop,
					marginBottom,
					marginLeft,
					marginRight,
					cBarWidth, 
					bgSkin);
			
			_spShowCase = new SPShowCase();
			_spNotice = new SPNotice();
			_spRecommand = new SPRecommend();
			_container.addChild(_spShowCase);
			_container.addChild(_spNotice);
			_container.addChild(_spRecommand);
		}
		
		override protected function SetLayoutMP(areaWidth:int, areaHeight:int):void{
			//trace("areaWidth: " + areaWidth + "     " + "areaHeight: " + areaHeight);
			
			_spShowCase.SetLayout( int(areaWidth*1.0), int(areaHeight*0.65) );
			_spNotice.SetLayout( int(areaWidth*0.35), int(areaHeight*0.35) );
			_spRecommand.SetLayout( int(areaWidth*0.65), int(areaHeight*0.35) );
			
			_spNotice.y = _spRecommand.y = int(areaHeight*0.65);
			_spRecommand.x = int(areaWidth*0.35);
		}
		
		/* Public Method
		* ---------------------------------------------------- */
		public function UpdateShowCase(xml:XML):void{
			var cmdName:String = xml.head.command;
			var itemGroup:ItemGroup = new ItemGroup();

			var cItem:XML;
			for each (cItem in xml.body.showcase.item)
			{
				var sVO:OnlineResHomeVO = new OnlineResHomeVO();
				sVO.ID = cItem.@id;
				sVO.Title = cItem.info.(@id == "title");
				sVO.Name = cItem.info.(@id == "name");
				sVO.Description = cItem.info.(@id == "description");
				sVO.Resource = cItem.info.(@id == "resource");
				sVO.Category = cItem.info.(@id == "category");
				sVO.CoverURL = cItem.info.(@id == "coverurl");
				itemGroup.AddVO(sVO);
			}
			_spShowCase.Refresh(itemGroup);
		}
		
		public function UpdateNotice(xml:XML):void{
			var cmdName:String = xml.head.command;
			var itemGroup:ItemGroup = new ItemGroup();
			
			var nItemXML:XML;
			for each (nItemXML in xml.body.notice.item)
			{
				var nVO:NoticeVO = new NoticeVO();
				nVO.ID = nItemXML.@id;
				nVO.Title = nItemXML.info.(@id == "title");
				nVO.Date = nItemXML.info.(@id == "date");
				nVO.Author = nItemXML.info.(@id == "author");
				nVO.Content = "";;
				itemGroup.AddVO(nVO);
			}
			_spNotice.Refresh(itemGroup);
		}
		
		public function UpdateRecommand(xml:XML):void{
			var cmdName:String = xml.head.command;
			var itemGroup:ItemGroup = new ItemGroup();
			
			var rItemXML:XML;
			for each (rItemXML in xml.body.recommend.item)
			{
				var rVO:OnlineResHomeVO = new OnlineResHomeVO();
				rVO.ID = rItemXML.@id;
				rVO.Title = rItemXML.info.(@id == "title");
				rVO.Name = rItemXML.info.(@id == "name");
				rVO.Description = rItemXML.info.(@id == "description");
				rVO.Resource = rItemXML.info.(@id == "resource");
				rVO.Category = rItemXML.info.(@id == "category");
				rVO.CoverURL = rItemXML.info.(@id == "coverurl");
				itemGroup.AddVO(rVO);
			}
			_spRecommand.Refresh(itemGroup);
		}
		
		override public function Dispose():void
		{
		}
	}
}